package cn.iocoder.yudao.module.pay.order.api;

import cn.iocoder.yudao.module.api.pay.order.PayOrderApi;
import cn.iocoder.yudao.module.api.pay.order.dto.PayOrderCreateDTO;
import cn.iocoder.yudao.module.api.pay.order.vo.PayOrderVO;
import cn.iocoder.yudao.module.pay.order.convert.PayOrderConvert;
import cn.iocoder.yudao.module.pay.order.dal.dataobject.PayOrderDO;
import cn.iocoder.yudao.module.pay.order.service.PayOrderService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 支付单 API 实现类
 *
 * @author 芋道源码
 */
@Service
public class PayOrderApiImpl implements PayOrderApi {

    @Resource
    private PayOrderService payOrderService;

    @Override
    public String createOrder(PayOrderCreateDTO dto) {
        return payOrderService.createOrder(dto).getNo();
    }

    @Override
    public PayOrderVO getOrderByNo(String no) {
        PayOrderDO order = payOrderService.getOrderByNo(no);
        return PayOrderConvert.INSTANCE.convertVO(order);
    }

    @Override
    public PayOrderVO getOrderByTradeNo(String tradeNo) {
        PayOrderDO order = payOrderService.getOrderByTradeNo(tradeNo);
        return PayOrderConvert.INSTANCE.convertVO(order);
    }

    @Override
    public void updatePayOrderPrice(String no, Integer payPrice) {
        payOrderService.updatePayOrderPrice(no, payPrice);
    }

    @Override
    public void closeOrderByNo(String no) {
        payOrderService.closeOrderByNo(no);
    }

    @Override
    public List<String> getPayNoByWeChatPayed(LocalDateTime minDateTime) {
        return payOrderService.getPayNoByWeChatPayed(minDateTime);
    }

}
